﻿package mortal.game.net.command
{
    import Framework.MQ.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.gengine.utils.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.view.chat.*;
    import mortal.game.view.chat.chatPanel.*;
    import mortal.game.view.chat.chatViewData.*;
    import mortal.game.view.systemSetting.*;
    import mortal.mvc.core.*;

    public class NoticeMsgCommand extends BroadCastCall
    {

        public function NoticeMsgCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_3:int = 0;
            var _loc_4:String = null;
            var _loc_5:String = null;
            var _loc_6:String = null;
            var _loc_2:* = param1.messageBase as SBroadcast;
            ChatMessageWorking.getNoticeContent(_loc_2);
            NetDispatcher.dispatchCmd(ServerCommand.NoticeMsg, _loc_2);
            if (_loc_2.area & EShowArea._EShowAreaMiddle)
            {
                _loc_4 = this.getHtml(_loc_2);
                if (_loc_4)
                {
                    MsgManager.showRollRadioMsg(_loc_4, 1, 2, _loc_2.priority);
                }
            }
            if (_loc_2.area & EShowArea._EShowAreaMiddleTop)
            {
                if (!SystemSetting.instance.isHideSystemTips.bValue)
                {
                    _loc_4 = this.getHtml(_loc_2);
                    if (_loc_4)
                    {
                        MsgManager.addBroadCast(_loc_4);
                    }
                }
            }
            if (_loc_2.area & EShowArea._EShowAreaChat)
            {
                _loc_6 = _loc_2.content;
                if (_loc_2.type == EChatType._EChatTypeGuild)
                {
                    GameController.chat.addTipMsg(_loc_6, ChatType.Union, ChatArea.Union, 2, _loc_2.miniPlayers, ChatStyle.getTitleColor(ChatType.Union));
                }
                else if (_loc_2.type == EChatType._EChatTypeSystem)
                {
                    GameController.chat.addBackStageMsg(_loc_6, _loc_2.miniPlayers);
                }
                if (_loc_2.type == EChatType._EChatTypeRumor || _loc_2.type == EChatType._EChatTypeCross)
                {
                    GameController.chat.addTypeRumorMsg(_loc_2.content, _loc_2.miniPlayers, ChatType.Legent);
                }
                if (_loc_2.type == EChatType._EChatTypeBattleField)
                {
                    GameController.chat.addTypeRumorMsg(_loc_2.content, _loc_2.miniPlayers, ChatType.Battlefield);
                }
                if (_loc_2.type == EChatType._EChatTypeMarket)
                {
                    GameController.chat.addTypeRumorMsg(_loc_2.content, _loc_2.miniPlayers, ChatType.Market);
                }
                if (_loc_2.type == EChatType._EChatTypeCopy)
                {
                    GameController.chat.addCopyMsg(_loc_2.content, _loc_2.miniPlayers);
                }
                if (_loc_2.type == EChatType._EChatTypeForce)
                {
                    _loc_5 = ChatType.Force;
                    GameController.chat.addTipMsg(_loc_2.content, _loc_5, ChatArea.Force, 2, _loc_2.miniPlayers, ChatStyle.getTitleColor(ChatType.System));
                }
                if (_loc_2.type == EChatType._EChatTypeSpace)
                {
                    _loc_5 = ChatType.Scene;
                    if (ChatMessageWorking.chatShowAreaData.indexOf(ChatMessageWorking.crossObj) > -1)
                    {
                        _loc_5 = ChatType.CrossServer;
                    }
                    GameController.chat.addTipMsg(_loc_2.content, _loc_5, ChatArea.Scene, 2, _loc_2.miniPlayers, ChatStyle.getTitleColor(ChatType.System));
                }
                if (_loc_2.type == EChatType._EChatTypeWorld || _loc_2.type == EChatType._EChatTypeReminder)
                {
                    GameController.chat.addTypeRumorMsg(_loc_2.content, _loc_2.miniPlayers, ChatType.Tips);
                }
            }
            if (_loc_2.area & EShowArea._EShowAreaFightInfo)
            {
                if (!GameMapUtil.curMapState.isTreasureHunt)
                {
                    if (_loc_2.type == EChatType._EChatTypeFightInfo)
                    {
                        if (!_loc_4)
                        {
                            _loc_4 = this.getHtml(_loc_2);
                        }
                        MsgManager.addTipText(_loc_4, MsgType.FightMsg);
                    }
                }
            }
            if (_loc_2.area & EShowArea._EShowAreaRightDown)
            {
                _loc_4 = this.getHtml(_loc_2, EShowArea._EShowAreaRightDown);
                if (_loc_4)
                {
                    MsgManager.showRollTipsMsg(_loc_4);
                }
            }
            if (_loc_2.area & EShowArea._EShowAreaMiddleDown)
            {
                _loc_4 = this.getHtml(_loc_2);
                if (_loc_4)
                {
                    MsgManager.showTaskTarget(_loc_4);
                }
            }
            return;
        }// end function

        private function getHtml(param1:SBroadcast, param2:int = -1) : String
        {
            var _loc_3:int = 0;
            var _loc_8:String = null;
            var _loc_4:int = 16777215;
            var _loc_5:* = ColorConfig.instance.getChatColor("Rumor");
            if (_loc_5)
            {
                _loc_4 = _loc_5.intColor;
            }
            var _loc_6:* = ChatMessageWorking.getCellDatasFilterHtml(param1.content, _loc_4, param1.miniPlayers);
            var _loc_7:String = "";
            var _loc_9:int = 0;
            while (_loc_9 < _loc_6.length)
            {
                
                if (_loc_6[_loc_9].type == CellDataType.RumorTran || _loc_6[_loc_9].type == CellDataType.RumorCopy)
                {
                }
                else
                {
                    _loc_8 = HTMLUtil.addColor(_loc_6[_loc_9].text, "#" + _loc_6[_loc_9].elementFormat.color.toString(16));
                    _loc_7 = _loc_7 + _loc_8;
                }
                _loc_9++;
            }
            return _loc_7;
        }// end function

    }
}
